/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xilinx;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 *
 * @author dani
 */
public class InterfazJFrame extends javax.swing.JFrame {

    /**
     * Creates new form InterfazJFrame
     */
    public InterfazJFrame() {
        initComponents();
         jTextPaneA.setToolTipText( "<html>El primer digito determina el signo</html>" );
         jTextPane8.setToolTipText( "<html>El primer digito determina el signo</html>" );
         jTextPaneC.setToolTipText( "<html>El primer digito determina el signo</html>" );
         jTextPaneP.setToolTipText( "<html>El primer digito determina el signo</html>" );
         jTextPaneOPMODE.setToolTipText( "<html>El primer digito determina el signo</html>" );
         jTextPanePCIN.setToolTipText( "<html>El primer digito determina el signo</html>" );
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPaneA = new javax.swing.JTextPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextPaneB = new javax.swing.JTextPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextPaneC = new javax.swing.JTextPane();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextPaneP = new javax.swing.JTextPane();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTextPanePCIN = new javax.swing.JTextPane();
        jSeparator1 = new javax.swing.JSeparator();
        jButtonOK = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTextPane6 = new javax.swing.JTextPane();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTextPane7 = new javax.swing.JTextPane();
        jScrollPane8 = new javax.swing.JScrollPane();
        jTextPane8 = new javax.swing.JTextPane();
        jLabel11 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel12 = new javax.swing.JLabel();
        jScrollPane9 = new javax.swing.JScrollPane();
        jTextPaneOPMODE = new javax.swing.JTextPane();
        jComboBox_potencia_A = new javax.swing.JComboBox();
        jComboBox_potencia_B = new javax.swing.JComboBox();
        jComboBox_potencia_C = new javax.swing.JComboBox();
        jComboBox_potencia_BCIN = new javax.swing.JComboBox();
        jComboBox_potencia_PCIN = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane10 = new javax.swing.JScrollPane();
        jTextPaneALUMODE = new javax.swing.JTextPane();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jComboBox_primerOperando = new javax.swing.JComboBox();
        jComboBox_segundoOperando = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        jComboBox_signo = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Proyecto fin de carrera");

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel1.setText("Entada de Datos");

        jLabel2.setText("A [17:0]");

        jLabel3.setText("B [17:0]");

        jLabel4.setText("C [47:0]");

        jTextPaneA.setToolTipText("");
        jScrollPane1.setViewportView(jTextPaneA);

        jScrollPane2.setViewportView(jTextPaneB);

        jScrollPane3.setViewportView(jTextPaneC);

        jLabel5.setText("P [17:0]");

        jScrollPane4.setViewportView(jTextPaneP);

        jLabel6.setText("PCIN [47.0]");

        jScrollPane5.setViewportView(jTextPanePCIN);

        jSeparator1.setBackground(new java.awt.Color(0, 153, 153));
        jSeparator1.setForeground(new java.awt.Color(153, 0, 153));
        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jButtonOK.setText("Ok");
        jButtonOK.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jButtonOKMousePressed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel7.setText("Datos de Salida");

        jLabel8.setText("BCOUNT [17:0]");

        jLabel9.setText("PCOUNT [47:0]");

        jLabel10.setText("P [47:0]");

        jTextPane6.setEditable(false);
        jScrollPane6.setViewportView(jTextPane6);

        jTextPane7.setEditable(false);
        jScrollPane7.setViewportView(jTextPane7);

        jTextPane8.setEditable(false);
        jScrollPane8.setViewportView(jTextPane8);

        jLabel11.setText("OPMODE [6:0]");

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel12.setText("Resultados");

        jScrollPane9.setViewportView(jTextPaneOPMODE);

        jComboBox_potencia_A.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Decimal", "Binario", "Octal", "Hexadecimal" }));

        jComboBox_potencia_B.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Decimal", "Binario", "Octal", "Hexadecimal" }));

        jComboBox_potencia_C.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Decimal", "Binario", "Octal", "Hexadecimal" }));

        jComboBox_potencia_BCIN.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Decimal", "Binario", "Octal", "Hexadecimal" }));

        jComboBox_potencia_PCIN.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Decimal", "Binario", "Octal", "Hexadecimal" }));

        jLabel13.setText("ALUMODE [6:0]");

        jScrollPane10.setViewportView(jTextPaneALUMODE);

        jLabel14.setText("Primer Operando");

        jLabel15.setText("Segundo Operando");

        jComboBox_primerOperando.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ZERO", "PCIN", "P", "C", "Shift(PCIN)", "Shift(P)" }));

        jComboBox_segundoOperando.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ZERO", "CIN", "(P + CIN)", "(A:B + CIN)", "(AxB + CIN)", "(C + CIN)", "(C + P + CIN)", "(A:B + C + CIN)" }));

        jLabel16.setText("Signo");

        jComboBox_signo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "+", "-" }));

        jLabel17.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel17.setText("Operacion a realizar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(40, 40, 40)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                    .addComponent(jLabel3)
                                                    .addComponent(jLabel2))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                            .addGroup(layout.createSequentialGroup()
                                                .addGap(1, 1, 1)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addGroup(layout.createSequentialGroup()
                                                        .addComponent(jLabel4)
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                    .addGroup(layout.createSequentialGroup()
                                                        .addComponent(jLabel5)
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                    .addGroup(layout.createSequentialGroup()
                                                        .addComponent(jLabel6)
                                                        .addGap(18, 18, 18)
                                                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                        .addGap(25, 25, 25)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jComboBox_potencia_PCIN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jComboBox_potencia_BCIN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jComboBox_potencia_B, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jComboBox_potencia_A, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jComboBox_potencia_C, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(109, 109, 109)
                                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(91, 91, 91)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jButtonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jComboBox_signo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(layout.createSequentialGroup()
                                                .addGap(95, 95, 95)
                                                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGap(0, 0, Short.MAX_VALUE)
                                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel14)
                                            .addComponent(jComboBox_primerOperando, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jComboBox_segundoOperando, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8)
                            .addComponent(jLabel10))
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane6)
                            .addComponent(jScrollPane7, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 336, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(133, 133, 133)
                        .addComponent(jLabel12)
                        .addGap(124, 124, 124))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel11)
                                    .addComponent(jLabel13))
                                .addGap(36, 36, 36)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jComboBox_potencia_A, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jComboBox_potencia_B, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel4)
                            .addComponent(jComboBox_potencia_C, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(26, 26, 26)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(15, 15, 15)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addComponent(jLabel5))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox_potencia_BCIN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jComboBox_potencia_PCIN, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(27, 27, 27)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(31, 31, 31)
                .addComponent(jLabel17)
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15)
                    .addComponent(jLabel16))
                .addGap(36, 36, 36)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox_primerOperando, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_segundoOperando, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_signo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 63, Short.MAX_VALUE)
                .addComponent(jButtonOK)
                .addContainerGap())
            .addComponent(jSeparator1)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addGap(44, 44, 44)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel11)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel13)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30)
                .addComponent(jLabel12)
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel8)
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(37, 37, 37)
                        .addComponent(jLabel9))
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel10)
                    .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(43, 43, 43))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonOKMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonOKMousePressed
        try {
            // TODO add your handling code here:
            accionBotonOK();
            
        } catch (Exception ex) {
            Logger.getLogger(InterfazJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonOKMousePressed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
             
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
 
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(InterfazJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(InterfazJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(InterfazJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(InterfazJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new InterfazJFrame().setVisible(true);
               
            }
        });


    }
    //variables
    // int valores de 32 bits maximo
    int valorDeA = 0;
    int valorDeB = 0;
    int valorDeC = 0;
    int[] Z = new int[3];
    int[] Y = new int[2];
    int[] X = new int[2];
    boolean error = false;
    String  primerOperando;
    String  segundoOperando;
    String  signo;
    boolean signo2;
    // long valores de 64 bit maximo
    long valorDeP = 0;
    long valorDePCIN = 0;
    

    
    
    public long cambioBase(String cadena, int limite, int potencia) throws Exception
    {
        try
        {
           boolean signo; //true positivo, false negativo 
          
           
           if(cadena.equals(""))
        	   return 0;
           char signo2= cadena.charAt(0);
           double maximo=Math.pow(2, limite);
            if(cadena.length()<2 &&  potencia!=10)
               throw new Exception("El numero en representacion en complemento necesita al menos dos digitos");
        
            //Caso de decimal ya esta transformado
           if(potencia == 10)
           {
               if(Math.pow(2, limite)>Long.parseLong(cadena, potencia) &&(-1)*Math.pow(2, limite)<Long.parseLong(cadena, potencia) )
                 return  Long.parseLong(cadena, potencia);
               else
                  throw new Exception("la cadena de digitos sobrepasa el limite establecido para dicho registro"); 
           }
        //Caso de binario hay que transformalos a sistema decimal tener en cuenta que esta en sitema complemento a dos    
          if(potencia == 2)
          {
                if (signo2=='1')
                    signo=false;
                else
                    if (signo2=='0')
                         signo=true;
                    else
                         throw new Exception("El primer digito del numero tiene que corresponder con el signo");
                for(int i=0;i<cadena.length();i++) //comprobamos que la cadena esta formada por 0s y 1s 
                {
                    if(cadena.charAt(i)=='0' || cadena.charAt(i)=='1' )
                        continue;
                    else
                         throw new Exception("Los caracteres introducidos no corresponde con valores binarios"); 
                }  
                if(Math.pow(2, limite)>Long.parseLong(cadena, potencia) &&(-1)*Math.pow(2, limite)<Long.parseLong(cadena, potencia) )
                    if(signo)
                        return ( Long.parseLong(cadena, potencia));
                    else //lo convertimos a complemento a dos
                     {
                        String subcadena=cadena.substring(1,cadena.length());
                        return ( -Long.parseLong(subcadena, potencia)-1);
                     }
                else
                  throw new Exception("la cadena de digitos sobrepasa el limite establecido para dicho registro");   
            }  
        //Caso de Octal hay que transformalos a sistema decimal tener en cuenta que esta en sitema complemento  
            if(potencia == 8)
            {
                if (signo2=='7')
                    signo=false;
                else
                    if(signo2=='0')
                        signo=true;
                    else
                        throw new Exception("El primer digito del numero tiene que corresponder con el signo");

                for(int i=0;i<cadena.length();i++)     
                {
                    if(cadena.charAt(i)=='0' || cadena.charAt(i)=='1'|| cadena.charAt(i)=='2'|| cadena.charAt(i)=='3'
                    || cadena.charAt(i)=='4' || cadena.charAt(i)=='5'|| cadena.charAt(i)=='6'|| cadena.charAt(i)=='7')
                        continue;
                    else
                        throw new Exception("Los caracteres introducidos no corresponde con valores en representación octal"); 
                 }  
                if(Math.pow(2, limite )>Long.parseLong(cadena, potencia) &&(-1)*Math.pow(2, limite)<Long.parseLong(cadena, potencia) )
                    if(signo)
                        return ( Long.parseLong(cadena, potencia));
                    else //lo convertimos a complemento a dos
                        {
                            String subcadena=cadena.substring(1,cadena.length());
                            return ( -Long.parseLong(subcadena, potencia)-1);
                        }
                else
                  throw new Exception("la cadena de digitos sobrepasa el limite establecido para dicho registro"); 
               }
       //Caso de Hexadecimal hay que transformalos a sistema decimal tener en cuenta que esta en sitema complemento  
         if(potencia == 16)
           {
                if (signo2=='F')
                    signo=false;
                else
                    if(signo2=='0')
                        signo=true;
                    else
                        throw new Exception("El primer digito del numero tiene que corresponder con el signo");

                for(int i=0;i<cadena.length();i++)     
                {
                    if(cadena.charAt(i)=='0' || cadena.charAt(i)=='1'|| cadena.charAt(i)=='2'|| cadena.charAt(i)=='3'
                        || cadena.charAt(i)=='4' || cadena.charAt(i)=='5'|| cadena.charAt(i)=='6'|| cadena.charAt(i)=='7'
                        || cadena.charAt(i)=='8' || cadena.charAt(i)=='9'|| cadena.charAt(i)=='a'|| cadena.charAt(i)=='A'
                        || cadena.charAt(i)=='b' || cadena.charAt(i)=='B'|| cadena.charAt(i)=='c'|| cadena.charAt(i)=='C'
                        || cadena.charAt(i)=='e' || cadena.charAt(i)=='E'|| cadena.charAt(i)=='f'|| cadena.charAt(i)=='F')
                            continue;
                    else
                            throw new Exception("Los caracteres introducidos no corresponde con valores en representación hexadecimal"); 
                }  
                if(Math.pow(2, limite )>Long.parseLong(cadena, potencia) &&(-1)*Math.pow(2, limite)<Long.parseLong(cadena, potencia) )
                    if(signo)
                        return ( Long.parseLong(cadena, potencia));
                    else //lo convertimos a complemento a dos
                    {
                        String subcadena=cadena.substring(1,cadena.length());
                        return ( -Long.parseLong(subcadena, potencia)-1);
                    }
                else
                  throw new Exception("la cadena de digitos sobrepasa el limite establecido para dicho registro"); 
            }  
          }
        catch(Exception e)
        {
            System.err.println(e.toString());
        }
        return 0;
    }
    
    public int obtenerPotencia(String valor)
    {
        int potencia=0;
            switch(valor)
        {
            case "Hexadecimal":{potencia=16; break;}
            case "Binario":{potencia=2; break;}
            case "Decimal":{potencia=10; break;}
            case "Octal":{potencia=8; break;}
        }
            return potencia;
    }
    
    //valor de A tiene la restriccion de 
    public void obtenerValorDeA() throws Exception
    {  
        int potenciaA;
        int limite=30;
        String  valor=jComboBox_potencia_A.getSelectedItem().toString();
        potenciaA=obtenerPotencia(valor);
        valorDeA = (int) (long)cambioBase(jTextPaneA.getText(),limite,potenciaA);
        System.out.println("valor de A: "+valorDeA);
    }
    
     //valor de B tiene la restriccion de 
    public void obtenerValorDeB() throws Exception
    {
        // valorDeB =(int) (long)cambioBaseHexadecimal(jTextPaneB.getText(),18);
        int potenciaB;
        int limite=18;
        String  valor=jComboBox_potencia_B.getSelectedItem().toString();
        potenciaB=obtenerPotencia(valor);
        valorDeB = (int) (long)cambioBase(jTextPaneB.getText(),limite,potenciaB);
        System.out.println("valor de B: "+valorDeB);
    }
     //valor de C tiene la restriccion de 
    public  void obtenerValorDeC() throws Exception
    {
        //valorDeC =(int) (long)cambioBaseHexadecimal(jTextPaneC.getText(),18);
        int potenciaC;
        int limite=48;
        String  valor=jComboBox_potencia_C.getSelectedItem().toString();
        potenciaC=obtenerPotencia(valor);
        valorDeC = (int) (long)cambioBase(jTextPaneC.getText(),limite,potenciaC);
        System.out.println("valor de C: "+valorDeC);
    }
   
     //valor de CIN tiene la restriccion de 
 /*   public  void obtenerValorDeCIN() 
    {
        activoCIN = jCheckBoxCIN.isSelected();      
    }*/
     //valor de P tiene la restriccion de 
    public void obtenerValorDeP() throws Exception
    {
        //valorDeBCIN = cambioBaseHexadecimal(jTextPaneBCIN.getText(),32);
        int potenciaP;
        int limite=18;
        String  valor=jComboBox_potencia_BCIN.getSelectedItem().toString();
        potenciaP=obtenerPotencia(valor);
        valorDeP = (int) (long)cambioBase(jTextPaneP.getText(),limite,potenciaP);
        System.out.println("valor de BCIN: "+valorDeP);
    }
    
    
         //valor de PCIN tiene la restriccion de 
    public void obtenerValorDePCIN() throws Exception
    {
        //valorDeBPCIN = cambioBaseHexadecimal(jTextPaneBCIN.getText(),32);
        int potenciaPCIN;
        int limite=18;
        String  valor=jComboBox_potencia_PCIN.getSelectedItem().toString();
        potenciaPCIN=obtenerPotencia(valor);
        valorDePCIN = (int) (long)cambioBase(jTextPaneP.getText(),limite,potenciaPCIN);
        System.out.println("valor de BCIN: "+valorDePCIN);
    }
    
    public void obtenerEntradas() throws Exception
    {
    	try
    	{
	        obtenerValorDeA();
	        obtenerValorDeB();
	        obtenerValorDeC();
	        obtenerValorDeP();
	        obtenerValorDePCIN();
    	}
        catch(Exception e)
        {
            System.out.println(e.toString());
        }
    }
    
    public void mostarValor(int valor) 
    {
        jTextPaneOPMODE.setText(""+valor);
    }
    

    public void reset()
    {
        valorDeA = 0;
        valorDeB = 0;
        valorDeC = 0;
        Z[0]=0;Z[1]=0;Z[2]=0;
        Y[0]=0;Y[1]=0;
        X[0]=0;X[1]=0;
    
    }



    public void completarSignos()
    {
    	
    	if(signo.equals("+"))
    		signo2=false;
    	else
    		signo2=true;
    }


    
    public void generadorOPMODE()
    {
        localizarPrimerOperando();
        localizarSegundoOperando();
        completarSignos();
    }
    public void localizarPrimerOperando()
    {
    	 
    	    switch(primerOperando)
            {
                case "ZERO":  
                        Z[2] = 0; Z[1] = 0; Z[0] = 0;
                        break;
                case"PCIN":
                		Z[2] = 0; Z[1] = 0; Z[0] = 1;
                        break;
                case "P":
                		Z[2] = 0; Z[1] = 1; Z[0] = 0;
                        break;
                case "C":  
                		Z[2] = 0; Z[1] = 1; Z[0] = 1;
                        break;
                case"Shift(P)":
                		Z[2] = 1; Z[1] = 1; Z[0] = 0;
                        break;
                case"Shift(PCIN)":
            		Z[2] = 1; Z[1] = 0; Z[0] = 1;
                    break;
            }
    	  
    }
    public void localizarSegundoOperando()
    {
    	
    	
	    switch(segundoOperando)
        {
	    	case "ZERO":
            case "CIN":  
	      		  Y[1]=0; Y[0]=0;//valor de Y = 0
	      		  X[1]=0; X[0]=0;//valor de X = 0
	      		  break;
            case"(P + CIN)":
		      		  Y[1]=0; Y[0]=0;//valor de Y = 0
		      		  X[1]=1; X[0]=0;//valor de X = P		
		      		  break;
            case "(A:B + CIN)":
		      		  Y[1]=0; Y[0]=0;//valor de Y = 0
		      		  X[1]=1; X[0]=1;//valor de X = A:B
        			  break;
            case "(AxB + CIN)":  
		      		  Y[1]=0; Y[0]=1;//valor de Y = CIN
		      		  X[1]=0; X[0]=1;//valor de X = 0
		      		  break;
            case"(C + CIN)":
		      		  Y[1]=1; Y[0]=1;//valor de Y = C
		      		  X[1]=0; X[0]=0;//valor de X = 0
		      		  break;
            case"(C + P + CIN)":
		      		  Y[1]=1; Y[0]=1;//valor de Y = 0
		      		  X[1]=1; X[0]=0;//valor de X = P
	                  break;
            case"(A:B + C + CIN)":
		      		  Y[1]=1; Y[0]=1;//valor de Y = 0
		      		  X[1]=1; X[0]=1;//valor de X = P
		      		  break;
             }
    	
    }

    public String comprobarOPEMODE(String primerOp, String segundoOp, String signo)
    {
    	primerOperando = primerOp;
    	segundoOperando = segundoOp;
    	this.signo=signo;
    	generadorOPMODE();
    	String resultado=Z[2]+""+Z[1]+""+Z[0]+ " "+ Y[1]+""+Y[0]+""+ " "+X[1]+""+X[0];
    	return resultado;
    }
    
    public void accionBotonOK() throws Exception
    {
        obtenerEntradas();
        primerOperando=jComboBox_primerOperando.getSelectedItem().toString();
        segundoOperando=jComboBox_segundoOperando.getSelectedItem().toString();
        signo=jComboBox_signo.getSelectedItem().toString();
        generadorOPMODE();
        String resultado=Z[2]+""+Z[1]+""+Z[0]+ " "+ Y[1]+""+Y[0]+""+ " "+X[1]+""+X[0];
        jTextPaneOPMODE.setText(resultado);

    }
      

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JButton jButtonOK;
    private javax.swing.JComboBox jComboBox_potencia_A;
    private javax.swing.JComboBox jComboBox_primerOperando;
    private javax.swing.JComboBox jComboBox_potencia_B;
    private javax.swing.JComboBox jComboBox_potencia_BCIN;
    private javax.swing.JComboBox jComboBox_potencia_C;
    private javax.swing.JComboBox jComboBox_potencia_PCIN;
    private javax.swing.JComboBox jComboBox_segundoOperando;
    private javax.swing.JComboBox jComboBox_signo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JTextPane jTextPane6;
    private javax.swing.JTextPane jTextPane7;
    private javax.swing.JTextPane jTextPane8;
    private javax.swing.JTextPane jTextPaneA;
    private javax.swing.JTextPane jTextPaneALUMODE;
    private javax.swing.JTextPane jTextPaneB;
    private javax.swing.JTextPane jTextPaneC;
    private javax.swing.JTextPane jTextPaneOPMODE;
    private javax.swing.JTextPane jTextPaneP;
    private javax.swing.JTextPane jTextPanePCIN;
    // End of variables declaration//GEN-END:variables
}
